#include<iostream>
using namespace std;
int main()
{
	int n, m, x;
	cin >> n >> m >> x;
	int arr[1001];
	int b[1010];
	for (int i = 0; i < n; i++) {
		cin >> arr[i];
	}
	for (int i = 0; i < m; i++) {
		cin >> b[i];
	}
	for (int i = 0 , j = m - 1; i < n; i++) {
		while (j && arr[i] + b[j] > x) {
			j--;
		}
		if (arr[i] + b[j] == x) {
			cout << i << " " << j << endl;
			return 0;
		}
	}

	return 0;
}